import Page
from Page import Personal
from Base.Base import Base
from selenium.webdriver.common.by import By


class PersonalNameToastPage(Base):
    """
    个人中心名称弹窗
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 名称弹窗标题
        self.name_title_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_title"))

        # 输入栏
        self.name_concern_input = (By.XPATH, Personal.RESOURCE_ID.format("et_input_name"))

        # 确认
        self.name_sure_btn = (By.XPATH, Personal.RESOURCE_ID.format("tv_sure"))

        # 取消
        self.name_cancel_btn = (By.XPATH, Personal.RESOURCE_ID.format("tv_cancel"))

    def get_title(self):
        """
        获取名称标题

        :return:
        """
        return self.find_element_o(self.name_title_text)

    def input_concern(self, index):
        """
        输入名称内容

        index为输入的内容
        :return:
        """
        self.input_text(self.name_concern_input, index)

    def click_sure(self):
        """
        点击确认按钮

        :return:
        """
        self.click_element(self.name_sure_btn)

    def click_cancel(self):
        """
        点击取消按钮

        :return:
        """
        self.click_element(self.name_cancel_btn)

    def is_display_personal_name(self):
        """
        是否存在名称页

        :return: bool
        """
        return self.is_display(self.name_title_text)
